import 'package:distribution_mall_flutter/assets.dart';
import 'package:distribution_mall_flutter/constant/cf_constant.dart';
import 'package:distribution_mall_flutter/constant/image_constant.dart';
import 'package:distribution_mall_flutter/entity/order/detail/order_detail_entity.dart';
import 'package:distribution_mall_flutter/provider/order/order_detail.dart';
import 'package:distribution_mall_flutter/utils/common_widget.dart';
import 'package:distribution_mall_flutter/utils/image_loader.dart';
import 'package:distribution_mall_flutter/utils/utils.dart';
import 'package:distribution_mall_flutter/widgets/card.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:skeletonizer/skeletonizer.dart';

// Skeleton.ignore(
//               child: NetworkImage(ImageConstant.orderAddressTitle),
//             )
class AddressCard extends ConsumerWidget {
  const AddressCard({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    Consignee? consignee = ref
        .watch(orderDetailProvider.select((value) => value.detal))
        ?.consignee;
    return Skeleton.ignore(
        child: EPCard(
            margin: const EdgeInsets.fromLTRB(EdgeConstant.edge10,
                EdgeConstant.edge10, EdgeConstant.edge10, 0),
            padding: const EdgeInsets.fromLTRB(EdgeConstant.edge15,
                EdgeConstant.edge15, EdgeConstant.edge5, EdgeConstant.edge15),
            enableClickEffect: true,
            height: 80,
            image: const DecorationImage(
                image: NetworkImage(ImageConstant.orderAddressTitle),
                alignment: Alignment.centerRight,
                fit: BoxFit.fitHeight),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Padding(
                    padding: const EdgeInsets.only(right: EdgeConstant.edge10),
                    child: ImageLoader.imageAsset(
                        Assets.assets_icons_address_local_png,
                        hasRoot: false,
                        width: 16,
                        height: 16)),
                Expanded(
                    child: Padding(
                  padding: const EdgeInsets.only(right: EdgeConstant.edge10),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding:
                            const EdgeInsets.only(bottom: EdgeConstant.edge5),
                        child: RichText(
                            maxLines: 1,
                            text: TextSpan(
                                text: consignee?.name ?? '',
                                style: const TextStyle(
                                    fontSize: FontConstant.f13,
                                    color: Colors.black),
                                children: [
                                  TextSpan(
                                    text: consignee?.phone ?? '',
                                    style: const TextStyle(
                                        fontSize: FontConstant.f11,
                                        color: ColorConstant.grey136),
                                  )
                                ])),
                      ),
                      Expanded(
                          child: Text(
                        Utils.formatAddress(consignee),
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                        style: const TextStyle(
                            color: Colors.black, fontSize: FontConstant.f11),
                      ))
                    ],
                  ),
                )),
                // Column(
                //   mainAxisAlignment: MainAxisAlignment.center,
                //   children: [
                //     CommonBtnWidget.arrowRight(
                //         onPressed: () {}, color: ColorConstant.grey114)
                //   ],
                // )
              ],
            )));
  }
}
